<html>
	<head>
	</head>
	<body>

		
		<!-- include SM2 library -->
		<script type="text/javascript" src="script/soundmanager2.js"></script>

		<!-- configure it for your use -->
		<script type="text/javascript">

		soundManager.url = 'swf/'; // directory where SM2 .SWFs live




		var mySound;
		
		//takes form data and parces it into the seperate variables. 
		function URLFromForm (form)
		{
			var songURL;
			var intFrom;
			var intTo;

			songURL = form.songLocation.value;
			intFrom = form.songStart.value;
			intTo = form.songEnd.value;
			PlayerRun (songURL, intFrom, intTo)
		}

		//actually plays the song
		function PlayerRun (songURL, intFrom, intTo) 
		{
						

			soundManager.onready(function(){

				// SM2 has loaded - now you can create and play sounds!

				mySound = new soundManager.createSound({
					id: songURL,
					url: songURL
				});
				
				mySound.play({
					from: intFrom,
					to: intTo,

					onstop: function() {
						Next (songURL, intFrom, intTo)
					},

					onfinish: function() {
						Next (songURL, intFrom, intTo)
					}
				});
			
			});


  		}

		//function that runs when a song finishes eather by being stoped or by coming to the end.
		function Next (songURL, intFrom, intTo)
		{
			//loops player
			//PlayerRun(songURL, intFrom, intTo);
			
			alert(songURL + ' Done');
		}



		// Optional: ontimeout() callback for handling start-up failure

		soundManager.ontimeout(function(){

			alert('Hrmm, SM2 could not start. Flash blocker involved? Show an error, etc.?');

		});

		</script>


 		<FORM NAME="myform" ACTION="" METHOD="GET">
			Enter something in the box: (try mp3/rain.mp3 or mp3/bass.mp3) <BR>
 	 		<p>
				Song location: <br/>
				<INPUT TYPE="text" NAME="songLocation">
			</p>
			<p>
				Song Start time (1000 = 1 second):<br/>
				<INPUT TYPE="text" NAME="songStart">
			</p>
			<p>		
				Song end time (1000 = 1 second):<br/>
				<INPUT TYPE="text" NAME="songEnd">
			</p>
 			<INPUT TYPE="button" NAME="button" Value="Play" onClick="URLFromForm(this.form)">
		</FORM>

		<INPUT TYPE="button" NAME="button2" Value="PlayAuto Song Section" onClick="javascript: PlayerRun('http://ec2-174-129-71-119.compute-1.amazonaws.com/tags/song1.mp3', '10000', '12000')">
		
		<INPUT TYPE="button" NAME="button3" Value="PlayAuto Rain" onClick="javascript: PlayerRun('mp3/rain.mp3')">

		<br/>
		<p>http://ec2-174-129-71-119.compute-1.amazonaws.com/tags/song1.mp3</p>

	</body>
</html>